package com.ica.model.facade;

import java.util.Collection;
import java.util.HashMap;

/**
 * @author   Hector
 */
public abstract class GenericFacadeImpl<E> implements GenericFacadeInterface<E> {
	
	/**
	 */
	protected HashMap<Long,E> elements;
	
	public GenericFacadeImpl() {
		
		elements = new HashMap<Long,E>();
	}
	
	public E getElement(long id) {
		
		return elements.get(id);
	}
	
	/**
	 * @return
	 * @uml.property  name="elements"
	 */
	public Collection<E> getElements() {

		return elements.values();
	}

	public void addElement(long id, E element) {
		
		elements.put(id, element);
	}

	public boolean removeElement(long id) {
		
		return elements.remove(id) != null;
	}

	public void replaceElement(long id, E element) {
		
		elements.remove(id);
		elements.put(id, element);
	}

}
